#!/usr/bin/env bash

git pull
mvn -DskipTests clean package -Pdev


echo "deploying system-service"

kill -9 $(lsof -ti tcp:8116)
cp -rf cw-services/system-server/target/system-server-1.0-SNAPSHOT.jar  /data/cwys/

echo ".......start system-service ...."
nohup java -Xms256m -Xmx512m -jar /data/cwys/system-server-1.0-SNAPSHOT.jar > /dev/null 2>&1 &
sleep 15
echo ".........end system-service......."

echo "deploying user-service"

kill -9 $(lsof -ti tcp:8114)
cp -rf cw-services/user-server/target/user-server-1.0-SNAPSHOT.jar  /data/cwys/

echo ".......start user-service ...."
nohup java -Xms256m -Xmx512m -jar /data/cwys/user-server-1.0-SNAPSHOT.jar > /dev/null 2>&1 &
sleep 15
echo ".........end user-service......."

echo "deploying trade-service"

kill -9 $(lsof -ti tcp:8115)
cp -rf cw-services/trade-server/target/trade-server-1.0-SNAPSHOT.jar  /data/cwys/

echo ".......start trade-service ...."
nohup java -Xms256m -Xmx512m -jar /data/cwys/trade-server-1.0-SNAPSHOT.jar > /dev/null 2>&1 &
sleep 15
echo ".........end trade-service......."

echo "deploying mall-service"

kill -9 $(lsof -ti tcp:8117)
cp -rf cw-services/mall-server/target/mall-server-1.0-SNAPSHOT.jar  /data/cwys/

echo ".......start mall-service ...."
nohup java -Xms256m -Xmx512m -jar /data/cwys/mall-server-1.0-SNAPSHOT.jar > /dev/null 2>&1 &
sleep 15
echo ".........end mall-service......."

echo "deploying activity-server"

kill -9 $(lsof -ti tcp:8113)
cp -rf cw-services/activity-server/target/activity-server-1.0-SNAPSHOT.jar  /data/cwys/

echo ".......start activity-service ...."
nohup java -Xms256m -Xmx512m -jar /data/cwys/activity-server-1.0-SNAPSHOT.jar > /dev/null 2>&1 &
sleep 15
echo ".........end activity-service......."


echo "deploying http-service"

kill -9 $(lsof -ti tcp:8118)
cp -rf cw-httpservices/cw-http/target/cw-http-1.0-SNAPSHOT.jar  /data/cwys/

echo ".........end http-service......."





